// 暂时使用这个
export const state = () => {
    user: null
}

export const mutations = {
    SET_USER(state, user) {
        state.user = user;
    }
}

export const actions = {
    nuxtServerInit({
        commit
    }, {
        req,
        route,
        app,
        store
    }) {
        if (req.session) { // 有session
            if (req.session.user && req.session.user.token) { // 用户登录
                const user = req.session.user;
                commit('SET_USER', user);
            }
        }
    },

    async login({
        commit
    }, context) {
        commit('SET_USER', context);
    }
}
